//
//  DetailViewController.m
//  TT
//
//  Created by lanou3g on 16/3/14.
//  Copyright © 2016年 Super磊. All rights reserved.
//

#import "DetailViewController.h"
#import "ReportViewController.h"

@interface DetailViewController ()<UITableViewDataSource,UITableViewDelegate,UIScrollViewDelegate>

@end

@implementation DetailViewController

- (void)loadView {
    self.detailV = [[DetailView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.view = self.detailV;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"姓名";
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:(UIBarButtonItemStyleDone) target:self action:@selector(leftAction)];
//    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ellipsis_32px_1130852_easyicon.net.png"] style:(UIBarButtonItemStylePlain) target:self action:@selector(rightAction)];
//    self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
//    self.detailV.tableV.delegate = self;
//    self.detailV.tableV.dataSource = self;

    [self.detailV.pageC addTarget:self action:@selector(changeAction) forControlEvents:(UIControlEventValueChanged)];
    self.detailV.scrollV.delegate = self;

}
#pragma mark tableView delegate
//- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
//    return 3;
//}
//- (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//    return 2;
//}
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//    
//    return nil;
//}


- (void)leftAction {
//    [self dismissViewControllerAnimated:YES completion:nil];
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)rightAction {
    UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:(UIAlertControllerStyleActionSheet)];
    UIAlertAction *first = [UIAlertAction actionWithTitle:[NSString stringWithFormat:@"举报 %@",@"艾琳"] style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        ReportViewController *reportVC = [[ReportViewController alloc] init];
        UINavigationController *na = [[UINavigationController alloc] initWithRootViewController:reportVC];
        [self presentViewController:na animated:YES completion:nil];
    }];
    [alertC addAction:first];
    UIAlertAction *second = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
        NSLog(@"取消");
        
    }];
    [alertC addAction:second];
    [self presentViewController:alertC animated:YES completion:nil];
    
}
#pragma mark 设置page以及scrollView
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    self.detailV.pageC.currentPage = self.detailV.scrollV.contentOffset.x / kScreenWidth;
}
//- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
//    self.detailV.pageC.currentPage = self.detailV.scrollV.contentOffset.x / kScreenWidth;
//}
- (void)changeAction {
    self.detailV.scrollV.contentOffset = CGPointMake(self.detailV.pageC.currentPage * kScreenWidth, 0);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
